<?php

class App_Abstract_Config extends App_Abstract
{
	/**
	 * 查询
	 *
	 * @return Tinyask_Db_Sql
	 */
	public function select()
	{
		return $this->db->select()->from('table.config');
	}

	/**
	 * 插入记录
	 *
	 * @param array $config
	 * @return integer
	 */
	public function insert(array $config)
	{
		return $this->db->query($this->db->insert('table.config')->row($config));
	}

	/**
	 * 更新记录
	 *
	 * @param array $config
	 * @param Tinyask_Db_Sql $condition
	 * @return integer
	 */
	public function update(array $config, Tinyask_Db_Sql $condition)
	{
		return $this->db->query($condition->update('table.config')->row($config));
	}

	/**
	 * 删除记录
	 *
	 * @param Tinyask_Db_Sql $condition
	 * @return integer
	 */
	public function delete(Tinyask_Db_Sql $condition)
	{
		return $this->db->query($condition->delete('table.config'));
	}

	/**
	 * 获取记录总数
	 *
	 * @param Tinyask_Db_Sql $condition
	 * @return integer
	 */
	public function size(Tinyask_Db_Sql $condition)
	{
		return $this->db->fetchObject($condition->select(array('COUNT(*)' => 'num'))->from('table.config'))->num;
	}
}
